import axios from 'axios'
axios.interceptors.request.use(req => {
  if (localStorage.LoginToken) {
    //浏览器将带有token的请求发送到服务器端
    req.headers && (req.headers.Authorization = localStorage.LoginToken)
  }
  return req
})
axios.interceptors.response.use(
  res => {
    return res.data
  },
  err => {}
)

const env_url = {
  dev: {
    baseUrl: 'http://localhost:8089/api',
    qkUrl: 'http://localhost:8089/container/markdown/'
  },
  pro: {
    baseUrl: 'https://www.ttzxh.icu/api',
    qkUrl: 'https://www.ttzxh.icu:81/container/markdown/'
  }
  // baseUrl:'https://www.ttzxh.icu/api'
  // baseUrl:'https://101.34.49.149/api'
  // baseUrl:'http://127.0.0.1:8080/api'
}
const { baseUrl, qkUrl } = env_url.pro
axios.defaults.timeout = 1800000
axios.defaults.baseURL = baseUrl

export { qkUrl, baseUrl }
export default axios
